//  bim与系统业务关联的接口
import { handleRequest } from '@/api/safetySupervision/index.js'
import request from '@/utils/request'
import { unionApiUrl } from '@/api/config'

/**
 * 绑定模型与业务
 * type: 'PROJECT' || 'WBS' || 'DANGER_PROJECT'
 */
export function bindModelWithProject(data) {
  return handleRequest(
    {
      url: '/bidding-model',
      method: 'post',
      data
    },
    {
      useCommon: true
    }
  )
}

// 获取绑定列表（项目）
export function getBindList(query) {
  return handleRequest(
    {
      url: '/bidding-model/list',
      method: 'get',
      params: query
    },
    {
      useCommon: true
    }
  )
}

// 解除绑定（项目）
export function deleteBind(query) {
  return handleRequest(
    {
      url: '/bidding-model/del',
      method: 'post',
      params: query
    },
    {
      useCommon: true
    }
  )
}

// 更新绑定记录（项目）
export function updateBind(data) {
  return handleRequest(
    {
      url: '/bidding-model/update',
      method: 'post',
      data
    },
    {
      useCommon: true
    }
  )
}

// 获取模型绑定的WBS信息
export function getWbsWithModel(query) {
  return handleRequest(
    {
      url: `/bidding-model/wbs/${query.modelId}`,
      method: 'get',
    },
    {
      useCommon: true
    }
  )
}

// 更新绑定记录(批量)
export function updateBindBatch(data) {
  return handleRequest(
    {
      url: '/bidding-model/batch',
      method: 'post',
      data
    },
    {
      useCommon: true
    }
  )
}

// 获取模型绑定的危大工程信息
export function getCriticalWithModel(query) {
  return handleRequest(
    {
      url: `/bidding-model/critical/${query.modelId}`,
      method: 'get',
    },
    {
      useCommon: true
    }
  )
}

/**
 * @description 获取问题列表(安全、质量)
 * @param {Object} data 
 */
export function getProblemListByModel(data) {
  return handleRequest({
    url: '/problem/list',
    method: 'post',
    data
  },
  {
    useApp: true
  }
  )
}

/**
 * @description 获取问题详情
 */
export function getProblemDetail(id) {
  return handleRequest({
    url: `/problem/details/${id}`,
    method: 'get'
  }, {
    useApp: true
  })
}

/**
 * 获取分享链接的过期时间UUid
 */
export function getShareUuid(params) {
  return request({
    url: unionApiUrl + '/bimModel/shareLinkValidity',
    method: 'post',
    params,
  })
}

/**
 * 校验分享链接有效期
 */
export function validateShareExpire(params) {
  return request({
    url: unionApiUrl + '/bimModel/checkLinkValidity',
    method: 'post',
    params,
  })
}